/* eslint-disable @typescript-eslint/no-explicit-any */
import { ChildItem } from '../ChildItem'
import DaoDaoMindMap from '../DaodaoMindMap'
import { EventEmitter } from '../EventEmitter'
import { Canvas } from 'fabric/fabric-impl'

export type ChildItemOption = {
	top?: number | undefined
	left?: number | undefined
	parent?: ChildItem | null
	icons?: {
		path: string, clickFn?: (event:{target: ChildItem}) => void, hoverFn?: (event:{target: ChildItem}) => void
	}[]
	[propName:string]: any
}

export type BasicItemOption = {
	top?: number | undefined
	left?: number | undefined
	[propName:string]: any
}

export type BoundingBox = {
	top: number
	bottom: number
	left: number
	right: number
}

export type EventItf = {
	target: ChildItem | DaoDaoMindMap | EventEmitter
}

export interface handlersItf {
	[propName:string]: (<T extends EventItf>(event:T) => void)[]
}

export interface ItemStyle {
	color?: string
	backgroundColor?: string
	padding?: number
	textBackgroundColor?: string
	textDecoration?: 'none' | 'line-through' | 'underline'
	lineHeight?: number
	fontSize?: number
	fontStyle?: 'normal' | 'italic' | 'oblique' | ''
}

export interface ItemTextStyle {
	color?: string
	textBackgroundColor?: string
	textDecoration?: 'none' | 'line-through' | 'underline'
	lineHeight?: number
	fontSize?: number
	fontStyle?: 'normal' | 'italic' | 'oblique' | ''
}

export interface ExportJsonItem {
	text?: string
	style?: ItemStyle
	img?: {
		src?: string
		width?: number
		height?: number
	}
	width?: number
	height?: number
	left?:number
	top?:number
	children?: ExportJsonItem[]
}

export type ICanvas = Canvas & {contextTop?: CanvasRenderingContext2D}

export type hasParentType<T> = T & {parent?: ChildItem | null}
